package cn.edu.zafu.bigdata.lwg;

import java.util.Random;
import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        //生成随机数
        Random r = new Random();
        int num = r.nextInt(100) + 1;
        //键盘录入猜测的数字
        Scanner sc = new Scanner(System.in);

        while (true){
            System.out.println("请输入您猜测的数字：");
            int i = sc.nextInt();
            //条件判断
            if (i > num){
                System.out.println("您猜大了");
            } else if (i < num) {
                System.out.println("您猜小了");
            }else {
                System.out.println("恭喜，您猜中了");
                break;
            }
        }
    }

}